import { extend} from "vee-validate";
import { required } from "vee-validate/dist/rules";

export const phoneReg =
  /^1((34[0-8])|(8\d{2})|(([35][0-35-9]|4[579]|66|7[35678]|9[1389])\d{1}))\d{7}$/;
export const passwordReg = /^[0-9a-zA-Z_]{6,18}$/;

  extend("phone", {
    // 函数返回true 检验通过 返回false 检验失败
    validate(val) {
      return phoneReg.test(val);
    },
    message: "请填写正确的手机号",
  });
  extend("phoneRequired", {
    ...required,
    message: "手机号必填",
  });

  extend("password", {
    validate(val) {
      return passwordReg.test(val);
    },
    message: "请填写正确的密码",
  });
  extend("passwordRequired", {
    ...required,
    message: "密码必填",
  });
  
  